package com.pug.zixun.controller.user;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pug.zixun.controller.BaseController;
import com.pug.zixun.domain.User;
import com.pug.zixun.service.user.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: WengYu
 * @CreateTime: 2022/05/18 16:52
 */
@RestController
@Slf4j
public class UserController extends BaseController {

    @Autowired
    private IUserService userService;


    @GetMapping("/user")
    public IPage<User> getUsers(int pageNo, int pageSize){
        Page<User> page = new Page<>(pageNo,pageSize);
        LambdaUpdateWrapper<User> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.eq(User::getIs_delete,0);
        lambdaUpdateWrapper.orderByDesc(User::getCreate_time);
        return userService.page(page,lambdaUpdateWrapper);
    }

}
